package com.oneday.ashop.console.resource;

import com.oneday.ashop.core.entity.Page;
import com.oneday.ashop.core.entity.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 资源控制层
 * Created by admin on 2016/7/2.
 */
@Controller
@RequestMapping("resource")
public class ResourceController {

    @Autowired
    private ResourceService resourceService;

    /**
     * 查抄资源分页数据
     * @param model
     */
    @RequestMapping("get_resource_page")
    public void getResourcePage(Page<Resource> page, Model model) {
        model.addAttribute("resources", resourceService.getALlResources());
    }

    /**
     * 添加资源
     */
    @RequestMapping("add_resource")
    public void addResource(Resource resource) {
        resourceService.addResource(resource);
    }

    /**
     * 删除资源
     * @param resourceId
     */
    @RequestMapping("delete_resource")
    public void deleteResource(Integer resourceId) {
        resourceService.deleteResource(resourceId);
    }
}
